package design.Component;

/**
 * Created by looper on 2017/8/17.
 */
public class ComponentTest {
  public static void main(String[] args) {
    Component root = new Branch("根");

    Component leafA = new Leaf("叶子节点A");
    Component leafB = new Leaf("叶子节点B");
    root.Add(leafA);
    root.Add(leafB);

    Component branchA = new Branch("分支A");
    Component branchB = new Branch("分支B");
    root.Add(branchA);
    root.Add(branchB);

    Component leafC = new Leaf("叶子节点C");
    Component branchC = new Branch("分支C");
    branchA.Add(leafC);
    branchA.Add(branchC);

    Component leafD = new Leaf("叶子节点D");
    branchC.Add(leafD);

    Component leafE = new Leaf("叶子节点E");
    Component leafF = new Leaf("叶子节点F");
    branchB.Add(leafE);
    branchB.Add(leafF);

    root.Display();

  }
}
